﻿using System.Xml;
using Blackbird.Common.Properties;
using Blackbird.Core.Editable.Base;

namespace Blackbird.Core.Editable.Map
{
    public class EditableMapList : EditableEntityCollection<EditableLayeredMap>
    {
        public override string TypeName
        {
            get { return Resources.EditableMapListTypeFriendlyName; }
        }

        protected override void ReadXmlAttributes(XmlReader reader)
        {
        }

        protected override void ReadXmlContent(XmlReader reader)
        {
            Items.Clear();
            reader.ReadStartElement("maps");
            reader.MoveToContent();
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                var map = new EditableLayeredMap();
                map.ReadXml(reader);
                Items.Add(map);
                reader.Read();
            }
            reader.ReadEndElement();
        }

        protected override void WriteXmlAttributes(XmlWriter writer)
        {
        }

        protected override void WriteXmlContent(XmlWriter writer)
        {
            writer.WriteStartElement("maps");
            foreach (EditableLayeredMap map in Items)
            {
                map.WriteXml(writer);
            }
            writer.WriteEndElement();
        }
    }
}